<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\search\AuthItemSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '发布管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="auth-item-index">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
//            ['class' => 'yii\grid\SerialColumn'],
            [
                'attribute'=>'id',
                'options' => ['width' => '80px'],
            ],
            [
                'attribute'=>'auth_app_id',
                'options' => ['width' => '60px'],
//                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return Html::a($model->authApp->showLogo(),['index','AuthItemSearch[auth_app_id]'=>$model->auth_app_id]);
                }
            ],
            [
                'attribute'=>'auth_account_id',
                'options' => ['width' => '60px'],
//                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return Html::a($model->authAccount->showAvatar(),['index','AuthItemSearch[auth_account_id]'=>$model->auth_account_id]).'<br/>'.$model->authAccount->showName();
                }
            ],
            'video_id',
            [
                'attribute'=>'title',
                'options' => ['width' => '250px'],
            ],
            [
                'attribute'=>'cover',
                'filter'=>false,
                'options' => ['width' => '70px'],
                'format'=>'raw',
                'value'=>function($model){
                    return '<a target="_blank" href="/agent/auth-item/show?id='.$model->id.'">'.$model->showCover().'</a>';
                }
            ],
            //'is_top',
            [

                'attribute'=>'comment_count',
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
//                    return Html::a($model->comment_count, ['auth-comment/index','AuthCommentSearch[item_id]'=>$model->id]);
                    return $model->comment_count;
                }
            ],
            [

                'attribute'=>'digg_count',
                'filter'=>false,
                'value'=>function($model){
                    return $model->digg_count;
                }
            ],
            [

                'attribute'=>'play_count',
                'filter'=>false,
                'value'=>function($model){
                    return $model->play_count;
                }
            ],
            [
                'label'=>'分享/转发/下载',
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    return $model->share_count.'/'.$model->forward_count.'/'.$model->download_count;
                }
            ],

            //'item_data:ntext',
            //'item_state',
            [

                'attribute'=>'create_time',
                'filter'=>false,
//                'format'=>'raw',
                'value'=>function($model){
                    return date('Y-m-d H:i',$model->create_time);
                }
            ],
            [
                'attribute'=>'timing',
                'filter'=>false,
//                'format'=>'raw',
                'value'=>function($model){
                    return $model->showTiming();
                }
            ],
            [
                'attribute'=>'post_time',
                'filter'=>false,
//                'format'=>'raw',
                'value'=>function($model){
                    return date('Y-m-d H:i',$model->post_time);
                }
            ],
            [
                'attribute'=>'state',
//                'filter'=>false,

                'filter'=>\app\models\AuthItem::$state_arr,
                'format'=>'html',
                'value'=>function($model){
                    return $model->showState();
                }
            ],
            [
                'label'=>'操作',
                'filter'=>false,
                'format'=>'raw',
                'value'=>function($model){
                    $str = Html::a('更新详情', '#here', ['class' => 'btn btn-success','onclick'=>'syncItem('.$model->id.')']);
                    $str .= '<br/>'.Html::a('更新评论', '#here', ['class' => 'btn btn-success','onclick'=>'syncComment('.$model->id.')']);
//                    $str .= '<br/>'.Html::a('删除', '#here', ['class' => 'btn btn-danger','onclick'=>'del('.$model->id.')']);
                    return $str;
                }
            ],

//            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>


</div>
